.class public Lcom/netease/newsreader/util/SkinUtil;
.super Ljava/lang/Object;
.source "SkinUtil.java"


# static fields
.field public static BRIGHT_NETEASE_SKIN_PACKAGE:Ljava/lang/String;

.field public static LOWER_LUXURIOUS_SKIN_PACKAGE:Ljava/lang/String;

.field public static SIMPLE_WHITE_SKIN_PACKAGE:Ljava/lang/String;

.field private static TAIL:Ljava/lang/String;

.field private static apkTemkDir:Ljava/lang/String;

.field private static sp:Landroid/content/SharedPreferences;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 33
    const-string v0, "com.netease.newsreader.lowerluxurious"

    sput-object v0, Lcom/netease/newsreader/util/SkinUtil;->LOWER_LUXURIOUS_SKIN_PACKAGE:Ljava/lang/String;

    .line 35
    const-string v0, "com.netease.newsreader.brightnetease"

    sput-object v0, Lcom/netease/newsreader/util/SkinUtil;->BRIGHT_NETEASE_SKIN_PACKAGE:Ljava/lang/String;

    .line 37
    const-string v0, "com.netease.newsreader.simplewhite"

    sput-object v0, Lcom/netease/newsreader/util/SkinUtil;->SIMPLE_WHITE_SKIN_PACKAGE:Ljava/lang/String;

    .line 39
    const-string v0, ".apk"

    sput-object v0, Lcom/netease/newsreader/util/SkinUtil;->TAIL:Ljava/lang/String;

    .line 44
    const-string v0, "/sdcard/netease/newsreader/tempapk/"

    sput-object v0, Lcom/netease/newsreader/util/SkinUtil;->apkTemkDir:Ljava/lang/String;

    .line 30
    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 30
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static InstallPackage(Landroid/content/Context;I)V
    .locals 7
    .parameter "ctx"
    .parameter "skinId"

    .prologue
    .line 130
    invoke-static {p0, p1}, Lcom/netease/newsreader/util/SkinUtil;->getCurrentSkinApkName(Landroid/content/Context;I)Ljava/lang/String;

    move-result-object v0

    .line 131
    .local v0, apkName:Ljava/lang/String;
    const-string v5, ""

    invoke-virtual {v5, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_0

    .line 147
    :goto_0
    return-void

    .line 133
    :cond_0
    invoke-static {p0, p1}, Lcom/netease/newsreader/util/SkinUtil;->getInputStreamBySkin(Landroid/content/Context;I)Ljava/io/InputStream;

    move-result-object v3

    .line 135
    .local v3, in:Ljava/io/InputStream;
    invoke-static {v3, v0}, Lcom/netease/newsreader/util/SkinUtil;->writeRawFile(Ljava/io/InputStream;Ljava/lang/String;)Ljava/io/File;

    move-result-object v1

    .line 137
    .local v1, file:Ljava/io/File;
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "file://"

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 141
    .local v2, fileName:Ljava/lang/String;
    new-instance v4, Landroid/content/Intent;

    const-string v5, "android.intent.action.VIEW"

    invoke-direct {v4, v5}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 142
    .local v4, intent:Landroid/content/Intent;
    const/high16 v5, 0x1000

    invoke-virtual {v4, v5}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;

    .line 144
    invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v5

    .line 145
    const-string v6, "application/vnd.android.package-archive"

    .line 144
    invoke-virtual {v4, v5, v6}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    .line 146
    invoke-virtual {p0, v4}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    goto :goto_0
.end method

.method public static deleteSkinApkFiles()V
    .locals 5

    .prologue
    .line 260
    new-instance v0, Ljava/io/File;

    sget-object v3, Lcom/netease/newsreader/util/SkinUtil;->apkTemkDir:Ljava/lang/String;

    invoke-direct {v0, v3}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 261
    .local v0, dir:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v3

    if-eqz v3, :cond_0

    .line 262
    invoke-virtual {v0}, Ljava/io/File;->listFiles()[Ljava/io/File;

    move-result-object v2

    .line 263
    .local v2, fs:[Ljava/io/File;
    array-length v4, v2

    const/4 v3, 0x0

    :goto_0
    if-lt v3, v4, :cond_1

    .line 266
    .end local v2           #fs:[Ljava/io/File;
    :cond_0
    return-void

    .line 263
    .restart local v2       #fs:[Ljava/io/File;
    :cond_1
    aget-object v1, v2, v3

    .line 264
    .local v1, f:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->delete()Z

    .line 263
    add-int/lit8 v3, v3, 0x1

    goto :goto_0
.end method

.method public static getCurrentContext(Landroid/content/Context;)Landroid/content/Context;
    .locals 5
    .parameter "ctx"

    .prologue
    .line 95
    invoke-static {p0}, Lcom/netease/newsreader/util/SkinUtil;->getCurrentSkinId(Landroid/content/Context;)I

    move-result v2

    .line 96
    .local v2, skinId:I
    if-nez v2, :cond_0

    .line 120
    .end local p0
    :goto_0
    return-object p0

    .line 97
    .restart local p0
    :cond_0
    const/4 v0, 0x0

    .line 99
    .local v0, context:Landroid/content/Context;
    packed-switch v2, :pswitch_data_0

    :goto_1
    move-object p0, v0

    .line 120
    goto :goto_0

    .line 101
    :pswitch_0
    move-object v0, p0

    .line 102
    goto :goto_1

    .line 105
    :pswitch_1
    :try_start_0
    sget-object v3, Lcom/netease/newsreader/util/SkinUtil;->LOWER_LUXURIOUS_SKIN_PACKAGE:Ljava/lang/String;

    const/4 v4, 0x2

    .line 104
    invoke-virtual {p0, v3, v4}, Landroid/content/Context;->createPackageContext(Ljava/lang/String;I)Landroid/content/Context;

    move-result-object v0

    .line 106
    goto :goto_1

    .line 109
    :pswitch_2
    sget-object v3, Lcom/netease/newsreader/util/SkinUtil;->BRIGHT_NETEASE_SKIN_PACKAGE:Ljava/lang/String;

    const/4 v4, 0x2

    .line 108
    invoke-virtual {p0, v3, v4}, Landroid/content/Context;->createPackageContext(Ljava/lang/String;I)Landroid/content/Context;

    move-result-object v0

    .line 110
    goto :goto_1

    .line 113
    :pswitch_3
    sget-object v3, Lcom/netease/newsreader/util/SkinUtil;->SIMPLE_WHITE_SKIN_PACKAGE:Ljava/lang/String;

    const/4 v4, 0x2

    .line 112
    invoke-virtual {p0, v3, v4}, Landroid/content/Context;->createPackageContext(Ljava/lang/String;I)Landroid/content/Context;
    :try_end_0
    .catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    goto :goto_1

    .line 116
    :catch_0
    move-exception v1

    .line 117
    .local v1, e:Landroid/content/pm/PackageManager$NameNotFoundException;
    const/4 v0, 0x0

    goto :goto_1

    .line 99
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_1
        :pswitch_2
        :pswitch_3
    .end packed-switch
.end method

.method private static getCurrentSkinApkName(Landroid/content/Context;I)Ljava/lang/String;
    .locals 1
    .parameter "ctx"
    .parameter "skinId"

    .prologue
    .line 211
    const-string v0, ""

    .line 224
    .local v0, filename:Ljava/lang/String;
    return-object v0
.end method

.method public static getCurrentSkinId(Landroid/content/Context;)I
    .locals 6
    .parameter "ctx"

    .prologue
    .line 233
    invoke-static {p0}, Landroid/preference/PreferenceManager;->getDefaultSharedPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;

    move-result-object v3

    sput-object v3, Lcom/netease/newsreader/util/SkinUtil;->sp:Landroid/content/SharedPreferences;

    .line 234
    sget-object v3, Lcom/netease/newsreader/util/SkinUtil;->sp:Landroid/content/SharedPreferences;

    const-string v4, "changeskin"

    const-string v5, "0"

    invoke-interface {v3, v4, v5}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    .line 235
    .local v2, skinid:Ljava/lang/String;
    const/4 v1, 0x0

    .line 237
    .local v1, id:I
    :try_start_0
    invoke-static {v2}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I
    :try_end_0
    .catch Ljava/lang/NumberFormatException; {:try_start_0 .. :try_end_0} :catch_0

    move-result v1

    .line 241
    :goto_0
    return v1

    .line 238
    :catch_0
    move-exception v0

    .line 239
    .local v0, e:Ljava/lang/NumberFormatException;
    invoke-virtual {v0}, Ljava/lang/NumberFormatException;->printStackTrace()V

    goto :goto_0
.end method

.method private static getInputStreamBySkin(Landroid/content/Context;I)Ljava/io/InputStream;
    .locals 1
    .parameter "ctx"
    .parameter "skinId"

    .prologue
    .line 200
    const/4 v0, 0x0

    return-object v0
.end method

.method private static getPackageNameById(I)Ljava/lang/String;
    .locals 1
    .parameter "skinId"

    .prologue
    .line 72
    const-string v0, ""

    .line 73
    .local v0, packageName:Ljava/lang/String;
    packed-switch p0, :pswitch_data_0

    .line 84
    :goto_0
    return-object v0

    .line 75
    :pswitch_0
    sget-object v0, Lcom/netease/newsreader/util/SkinUtil;->LOWER_LUXURIOUS_SKIN_PACKAGE:Ljava/lang/String;

    .line 76
    goto :goto_0

    .line 78
    :pswitch_1
    sget-object v0, Lcom/netease/newsreader/util/SkinUtil;->BRIGHT_NETEASE_SKIN_PACKAGE:Ljava/lang/String;

    .line 79
    goto :goto_0

    .line 81
    :pswitch_2
    sget-object v0, Lcom/netease/newsreader/util/SkinUtil;->SIMPLE_WHITE_SKIN_PACKAGE:Ljava/lang/String;

    goto :goto_0

    .line 73
    nop

    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_0
        :pswitch_1
        :pswitch_2
    .end packed-switch
.end method

.method public static isPkgInstalled(Landroid/content/Context;I)Z
    .locals 5
    .parameter "ctx"
    .parameter "skinId"

    .prologue
    const/4 v3, 0x0

    .line 55
    invoke-static {p1}, Lcom/netease/newsreader/util/SkinUtil;->getPackageNameById(I)Ljava/lang/String;

    move-result-object v1

    .line 57
    .local v1, packageName:Ljava/lang/String;
    invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v2

    .line 59
    .local v2, pm:Landroid/content/pm/PackageManager;
    const/4 v4, 0x0

    :try_start_0
    invoke-virtual {v2, v1, v4}, Landroid/content/pm/PackageManager;->getPackageInfo(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;
    :try_end_0
    .catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    .line 63
    const/4 v3, 0x1

    :goto_0
    return v3

    .line 60
    :catch_0
    move-exception v0

    .line 61
    .local v0, e:Landroid/content/pm/PackageManager$NameNotFoundException;
    goto :goto_0
.end method

.method public static unInstallPkg(Landroid/content/Context;I)V
    .locals 4
    .parameter "ctx"
    .parameter "skinId"

    .prologue
    .line 250
    invoke-static {p1}, Lcom/netease/newsreader/util/SkinUtil;->getPackageNameById(I)Ljava/lang/String;

    move-result-object v0

    .line 251
    .local v0, packageName:Ljava/lang/String;
    invoke-static {v0}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    .line 252
    .local v1, packageURI:Landroid/net/Uri;
    new-instance v2, Landroid/content/Intent;

    const-string v3, "android.intent.action.DELETE"

    invoke-direct {v2, v3, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V

    .line 253
    .local v2, uninstallIntent:Landroid/content/Intent;
    invoke-virtual {p0, v2}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    .line 254
    return-void
.end method

.method private static writeRawFile(Ljava/io/InputStream;Ljava/lang/String;)Ljava/io/File;
    .locals 8
    .parameter "in"
    .parameter "outFile"

    .prologue
    .line 157
    new-instance v1, Ljava/io/File;

    sget-object v6, Lcom/netease/newsreader/util/SkinUtil;->apkTemkDir:Ljava/lang/String;

    invoke-direct {v1, v6}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 158
    .local v1, dir:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v6

    if-nez v6, :cond_0

    .line 159
    invoke-virtual {v1}, Ljava/io/File;->mkdirs()Z

    .line 160
    :cond_0
    new-instance v5, Ljava/io/File;

    new-instance v6, Ljava/lang/StringBuilder;

    sget-object v7, Lcom/netease/newsreader/util/SkinUtil;->apkTemkDir:Ljava/lang/String;

    invoke-static {v7}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v6, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-direct {v5, v6}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 162
    .local v5, of:Ljava/io/File;
    :try_start_0
    new-instance v3, Ljava/io/FileOutputStream;

    invoke-direct {v3, v5}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 163
    .local v3, fouts:Ljava/io/FileOutputStream;
    const/16 v6, 0x400

    new-array v0, v6, [B

    .line 164
    .local v0, b:[B
    const/4 v4, -0x1

    .line 165
    .local v4, i:I
    :goto_0
    invoke-virtual {p0, v0}, Ljava/io/InputStream;->read([B)I

    move-result v4

    const/4 v6, -0x1

    if-ne v4, v6, :cond_1

    .line 169
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->flush()V

    .line 170
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->close()V

    .line 171
    invoke-virtual {p0}, Ljava/io/InputStream;->close()V

    .line 177
    .end local v0           #b:[B
    .end local v3           #fouts:Ljava/io/FileOutputStream;
    .end local v4           #i:I
    :goto_1
    return-object v5

    .line 167
    .restart local v0       #b:[B
    .restart local v3       #fouts:Ljava/io/FileOutputStream;
    .restart local v4       #i:I
    :cond_1
    const/4 v6, 0x0

    invoke-virtual {v3, v0, v6, v4}, Ljava/io/FileOutputStream;->write([BII)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 173
    .end local v0           #b:[B
    .end local v3           #fouts:Ljava/io/FileOutputStream;
    .end local v4           #i:I
    :catch_0
    move-exception v2

    .line 174
    .local v2, e:Ljava/lang/Exception;
    invoke-virtual {v2}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_1
.end method
